In [1]:
import psychic
import numpy as np
In [2]:
from scipy.io import loadmat
m = loadmat('p300/Subject_A_Train.mat')
print m.keys()
In [59]:
def cl(letter):
alphabet = [['A', 'B', 'C', 'D', 'E', 'F'],
['G', 'H', 'I', 'J', 'K', 'L'],
['M', 'N', 'O', 'P', 'Q', 'R'],
['S', 'T', 'U', 'V', 'W', 'X'],
['Y', 'Z', '1', '2', '3', '4'],
['5', '6', '7', '8', '9', '_']]
In [53]:
mdict = dict([(i, 'column %d' % i) for i in range(1,7)] + [(i+6, 'row %d' % i) for i in range(1,7)])
def process_trial(data, labels, target):
d = psychic.DataSet(data.T, labels=labels.astype(int)+1, ids=np.arange(data.shape[0])/240.)
flashes = psychic.nodes.Slice(mdict, (0, 0.7)).train_apply(d)
return flashes
In [58]:
train = psychic.concatenate([process_trial(m['Signal'][i,:,:], m['StimulusCode'][i,:], m['TargetChar'][0][i]) for i in range(85)], ignore_index=True)
In [47]:
print process_trial(m['Signal'][0,:], m['StimulusType'][0,:])
In [57]:
m['TargetChar'][0]
Out[57]:
In [13]:
plot(m['StimulusType'][0,:])
Out[13]:
In [ ]: